
const dictionary = {
  name: "John",
  age: 25,
  city: "New York"
};

type Dictionary<T> = {
  [key: string]: T;
};

function getKeys<T>(obj: Dictionary<T>): Array<keyof typeof obj> {
  return Object.keys(obj) as Array<keyof typeof obj>;
}

const keys: Array<keyof typeof dictionary> = getKeys(dictionary);
console.log(keys); // 输出：[ 'name', 'age', 'city' ]